package com.muy.json.view.window.redis.editor;

import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorLocation;
import com.intellij.openapi.fileEditor.FileEditorState;
import com.intellij.openapi.fileEditor.FileEditorStateLevel;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.beans.PropertyChangeListener;

/**
 * @Author jiyanghuang
 * @Date 2023/10/9 22:51
 */
public class JsonEditor extends UserDataHolderBase implements FileEditor {

    private JsonVirtualFile jsonVirtualFile;

    public JsonEditor(VirtualFile file) {
        this.jsonVirtualFile = (JsonVirtualFile) file;
    }

    @Override
    public @NotNull JComponent getComponent() {
        return jsonVirtualFile.getPanelCompare();
    }

    @Override
    public @Nullable JComponent getPreferredFocusedComponent() {
        return null;
    }

    @Override
    public @Nls(capitalization = Nls.Capitalization.Title) @NotNull String getName() {
        return "JsonEditor";
    }

    @Override
    public @NotNull FileEditorState getState(@NotNull FileEditorStateLevel level) {
        return FileEditor.super.getState(level);
    }

    @Override
    public void setState(@NotNull FileEditorState state) {

    }

    @Override
    public boolean isModified() {
        return false;
    }

    @Override
    public boolean isValid() {
        return true;
    }

    @Override
    public void addPropertyChangeListener(@NotNull PropertyChangeListener listener) {

    }

    @Override
    public void removePropertyChangeListener(@NotNull PropertyChangeListener listener) {

    }

    @Override
    public @Nullable FileEditorLocation getCurrentLocation() {
        return null;
    }

    /**
     * 必须实现
     * @return
     */
    @Override
    public VirtualFile getFile() {
        return jsonVirtualFile;
    }

    @Override
    public void dispose() {

    }
}
